//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __USBMSFDEP_H__
#define __USBMSFDEP_H__

// return codes
#define EXECUTE_PASS                        0x00000000
#define EXECUTE_FAIL                        0x00000001
#define EXECUTE_ERROR                       0x00000002

// Direction flags
#define DATA_OUT            0x00000000
#define DATA_IN             0x00000001

// Command block
typedef struct _TRANSPORT_COMMAND {
    DWORD Flags;            // [in]  - DATA_IN or DATA_OUT
    DWORD Timeout;          // [in]  - timeout for this command block; not used
    DWORD Length;           // [in]  - length of the command block buffer
    PVoid CommandBlock;     // [in]  - address of the command block buffer
} TRANSPORT_COMMAND, *PTRANSPORT_COMMAND;

// Data block
typedef struct _TRANSPORT_DATA_BUFFER {
    DWORD RequestLength;    // [in]  - requested length
    DWORD TransferLength;   // [out] - number of bytes actually transferred
    PVoid DataBlock;        // [in]  - address of the data buffer
    DWORD DataOffset;        // [in]  - offset on the data buffer
} TRANSPORT_DATA, *PTRANSPORT_DATA;


// Initialize a mass storage device.
ECode STORE_Init( wchar_t *lpcszContext );

// Close a mass storage device.
ECode STORE_Close();

// Determine whether a mass storage command is supported.
//
//    ptcCommand - the target command
//
//    pfDataStageRequired - the command has a data stage
//    (if the command is supported)
//
//    pdwDirection - the direction of the data stage
//    (if the command is supported)
//
//    pdwDataSize - the size of the data stage (if the command
//    is supported)
EXTERN_C BOOL STORE_IsCommandSupported( PTRANSPORT_COMMAND  ptcCommand,
                               PBOOL               pfDataStageRequired,
                               PDWORD              pdwDirection,
                               PDWORD              pdwDataSize );


// Execute a mass storage command.
//
//    ptcCommand - the target command
//
//    ptdData - data associated with the command (may be NULL)
DWORD STORE_ExecuteCommand( PTRANSPORT_COMMAND  ptcCommand,
                            PTRANSPORT_DATA     ptdData );

#endif // __USBMSFDEP_H__

